/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package View;

import Model.DBServices;
import com.sun.org.apache.regexp.internal.StreamCharacterIterator;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.ListModel;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author Mohamed
 */
public class Home extends javax.swing.JFrame {

    /**
     * Creates new form Home
     */
    DBServices data;
    private int courseName[];
    Student student;
    DefaultListModel list2 ;
    DefaultListModel list1;
    Course course ;
    
    boolean check ;
    int count=0;

    public Home() {
        initComponents();
        setLocationRelativeTo(null);
        jLayeredPane7.setVisible(false);
        jLayeredPane4.setVisible(true);
        jLayeredPane2.setVisible(false);
        jLayeredPane3.setVisible(false);
        jLayeredPane8.setVisible(false);
        jLayeredPane9.setVisible(false);
        data = new DBServices();
        list2 = new DefaultListModel();


    }

    
    public String getStudentEmail() {
        return student.getEmail();
    }
    public int getStudentId() {
        return student.getId();
    }
    
    public Home(String name , int id ) {


        initComponents();
        setLocationRelativeTo(null);
        jLayeredPane7.setVisible(false);
        jLayeredPane4.setVisible(true);
        jLayeredPane2.setVisible(false);
        jLayeredPane3.setVisible(false);
        jLayeredPane8.setVisible(false);
        jLayeredPane9.setVisible(false);
        data = new DBServices();
        setProfile(id);
        jLabel7.setText(name);
        list2 = new DefaultListModel();
    }

    public void setProfile(int id) {


        student = new Student();
        student = data.getProfile(id);


        int code = student.getId();
        String c = Integer.toString(code);
        jLabel10.setText(c);
        jLabel9.setText(student.getFullName());
        jLabel12.setText(student.getEmail());
        jLabel16.setText(student.getGender());
        jLabel20.setText(student.getAddress());

        int phone = student.getPhone();
        String p = Integer.toString(phone);
        jLabel14.setText(p);

        int level = student.getLevel();
        String l = Integer.toString(level);
        jLabel18.setText(l);


    }
    
    
    public void addCourse(){
    
     
         check = false ;
        ArrayList<String> arr = new ArrayList<String>();
        course = new Course();
        int size = list2.getSize();
        int countcourse = data.getcountcourses(student.getId());
         count = size + countcourse ;
       
           for (int i = 0; i<size; i++){
           
              arr.add(list2.getElementAt(i).toString());
            
           }
           
           if (count <=6){
           
           for(int j = 0 ; j < arr.size() ; j++){
           
               String coursecode = data.courseCode(arr.get(j));
              check = data.regist( student.getId() , coursecode);
           }
          
           if(check == true){
           
               JOptionPane.showMessageDialog(null,"Done!!");
           }
       
           
           else{
               JOptionPane.showMessageDialog(null,"Not Regist" );
           }
           }
       
       else{
       
           //jButton3.setEnabled(false);
           
          JOptionPane.showMessageDialog(null,"Select only 6 courses");
       }
        
        
       
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane4 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLayeredPane4 = new javax.swing.JLayeredPane();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLayeredPane7 = new javax.swing.JLayeredPane();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList3 = new javax.swing.JList();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList4 = new javax.swing.JList();
        jScrollPane7 = new javax.swing.JScrollPane();
        jLabel23 = new javax.swing.JLabel();
        jLayeredPane8 = new javax.swing.JLayeredPane();
        jScrollPane6 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        jButton5 = new javax.swing.JButton();
        jLabel27 = new javax.swing.JLabel();
        jLayeredPane9 = new javax.swing.JLayeredPane();
        jScrollPane3 = new javax.swing.JScrollPane();
        jList5 = new javax.swing.JList();
        jScrollPane5 = new javax.swing.JScrollPane();
        jList6 = new javax.swing.JList();
        jButton4 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        jLayeredPane2 = new javax.swing.JLayeredPane();
        jPanel4 = new javax.swing.JPanel();
        jLayeredPane5 = new javax.swing.JLayeredPane();
        jScrollPane8 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        jLayeredPane3 = new javax.swing.JLayeredPane();
        jPanel5 = new javax.swing.JPanel();
        jLayeredPane6 = new javax.swing.JLayeredPane();
        jLayeredPane10 = new javax.swing.JLayeredPane();
        jLabel9 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jLabel22 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jButton9 = new javax.swing.JButton();

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane4.setViewportView(jList1);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/cooltext1505159923.png"))); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseClicked(evt);
            }
        });

        jLayeredPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLayeredPane1MouseClicked(evt);
            }
        });

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/cooltext1509344764.png"))); // NOI18N
        jLabel2.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel2MouseClicked(evt);
            }
        });

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/cooltext1509360640.png"))); // NOI18N
        jLabel3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel3MouseClicked(evt);
            }
        });

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/cooltext1509366820.png"))); // NOI18N
        jLabel4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel4MouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel3)
                    .addComponent(jLabel2))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(66, 66, 66)
                .addComponent(jLabel2)
                .addGap(53, 53, 53)
                .addComponent(jLabel3)
                .addGap(62, 62, 62)
                .addComponent(jLabel4)
                .addContainerGap(93, Short.MAX_VALUE))
        );

        jPanel3.setBounds(0, 0, 110, 350);
        jLayeredPane1.add(jPanel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLayeredPane4.setBackground(new java.awt.Color(255, 255, 255));

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/cooltext1516484171.png"))); // NOI18N
        jLabel5.setBounds(120, 60, 350, 50);
        jLayeredPane4.add(jLabel5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel6.setFont(new java.awt.Font("Trebuchet MS", 1, 14));
        jLabel6.setText("Welcome ");
        jLabel6.setBounds(40, 170, 80, 20);
        jLayeredPane4.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel7.setFont(new java.awt.Font("Traditional Arabic", 1, 24));
        jLabel7.setBounds(120, 170, 410, 20);
        jLayeredPane4.add(jLabel7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 24));
        jLabel8.setText("Now you can registe your courses");
        jLabel8.setBounds(50, 230, 440, 30);
        jLayeredPane4.add(jLabel8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLayeredPane4.setBounds(110, 0, 680, 350);
        jLayeredPane1.add(jLayeredPane4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton1.setFont(new java.awt.Font("Tahoma", 1, 14));
        jButton1.setForeground(new java.awt.Color(255, 102, 0));
        jButton1.setText(">>");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jButton1.setBounds(310, 80, 70, 25);
        jLayeredPane7.add(jButton1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton2.setFont(new java.awt.Font("Tahoma", 1, 14));
        jButton2.setForeground(new java.awt.Color(255, 102, 0));
        jButton2.setText("<<");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jButton2.setBounds(310, 160, 70, 25);
        jLayeredPane7.add(jButton2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton3.setFont(new java.awt.Font("Tahoma", 1, 14));
        jButton3.setForeground(new java.awt.Color(255, 102, 0));
        jButton3.setText("OK");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jButton3.setBounds(310, 240, 70, 25);
        jLayeredPane7.add(jButton3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jScrollPane1.setViewportView(jList3);

        jScrollPane1.setBounds(10, 10, 210, 320);
        jLayeredPane7.add(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jScrollPane2.setViewportView(jList4);

        jScrollPane2.setBounds(460, 10, 210, 320);
        jLayeredPane7.add(jScrollPane2, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jScrollPane7.setBounds(40, 110, 90, 80);
        jLayeredPane7.add(jScrollPane7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel23.setFont(new java.awt.Font("Perpetua Titling MT", 1, 10));
        jLabel23.setForeground(new java.awt.Color(0, 0, 153));
        jLabel23.setBounds(220, 290, 240, 30);
        jLayeredPane7.add(jLabel23, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLayeredPane7.setBounds(110, 0, 680, 350);
        jLayeredPane1.add(jLayeredPane7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLayeredPane8.setBackground(new java.awt.Color(255, 255, 255));

        jScrollPane6.setViewportView(jList2);

        jScrollPane6.setBounds(140, 30, 460, 160);
        jLayeredPane8.add(jScrollPane6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton5.setFont(new java.awt.Font("Tahoma", 1, 14));
        jButton5.setText("Delete");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jButton5.setBounds(280, 230, 180, 30);
        jLayeredPane8.add(jButton5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel27.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel27.setForeground(new java.awt.Color(255, 51, 0));
        jLabel27.setBounds(40, 280, 320, 40);
        jLayeredPane8.add(jLabel27, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLayeredPane8.setBounds(109, -1, 690, 350);
        jLayeredPane1.add(jLayeredPane8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jScrollPane3.setViewportView(jList5);

        jScrollPane3.setBounds(450, 60, 190, 270);
        jLayeredPane9.add(jScrollPane3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jScrollPane5.setViewportView(jList6);

        jScrollPane5.setBounds(40, 70, 180, 260);
        jLayeredPane9.add(jScrollPane5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton4.setFont(new java.awt.Font("Tahoma", 1, 14));
        jButton4.setText("OK");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jButton4.setBounds(300, 230, 60, 30);
        jLayeredPane9.add(jButton4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton7.setFont(new java.awt.Font("Tahoma", 1, 18));
        jButton7.setText("<<");
        jButton7.setBounds(300, 160, 63, 31);
        jLayeredPane9.add(jButton7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton8.setFont(new java.awt.Font("Tahoma", 1, 18));
        jButton8.setText(">>");
        jButton8.setBounds(300, 80, 63, 31);
        jLayeredPane9.add(jButton8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel24.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel24.setForeground(new java.awt.Color(255, 0, 0));
        jLabel24.setBounds(40, 30, 220, 20);
        jLayeredPane9.add(jLabel24, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel25.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel25.setForeground(new java.awt.Color(51, 0, 204));
        jLabel25.setBounds(390, 20, 240, 20);
        jLayeredPane9.add(jLabel25, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel26.setFont(new java.awt.Font("Tahoma", 1, 14));
        jLabel26.setForeground(new java.awt.Color(0, 0, 204));
        jLabel26.setBounds(230, 300, 210, 30);
        jLayeredPane9.add(jLabel26, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLayeredPane9.setBounds(130, 0, 660, 340);
        jLayeredPane1.add(jLayeredPane9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane1.addTab("", new javax.swing.ImageIcon(getClass().getResource("/View/cooltext1516474980.png")), jLayeredPane1); // NOI18N

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 110, Short.MAX_VALUE)
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 350, Short.MAX_VALUE)
        );

        jPanel4.setBounds(0, 0, 110, 350);
        jLayeredPane2.add(jPanel4, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null},
                {null, null, null, null, null, null, null}
            },
            new String [] {
                "Time", "Straday", "Sunday", "Monday", "Tuesday", "Wednesday ", "Thursday "
            }
        ) {
            Class[] types = new Class [] {
                java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane8.setViewportView(jTable1);

        jScrollPane8.setBounds(10, 20, 600, 300);
        jLayeredPane5.add(jScrollPane8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLayeredPane5.setBounds(110, 0, 680, 350);
        jLayeredPane2.add(jLayeredPane5, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane1.addTab("", new javax.swing.ImageIcon(getClass().getResource("/View/cooltext1516476568.png")), jLayeredPane2); // NOI18N

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 110, Short.MAX_VALUE)
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 350, Short.MAX_VALUE)
        );

        jPanel5.setBounds(0, 0, 110, 350);
        jLayeredPane3.add(jPanel5, javax.swing.JLayeredPane.DEFAULT_LAYER);
        jLayeredPane6.setBounds(110, 0, 680, 350);
        jLayeredPane3.add(jLayeredPane6, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane1.addTab("", new javax.swing.ImageIcon(getClass().getResource("/View/cooltext1516477783.png")), jLayeredPane3); // NOI18N

        jLabel9.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel9.setBounds(260, 30, 220, 20);
        jLayeredPane10.add(jLabel9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel11.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel11.setText("User Full Name :");
        jLabel11.setBounds(60, 30, 120, 15);
        jLayeredPane10.add(jLabel11, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel13.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel13.setText("User Code :");
        jLabel13.setBounds(60, 70, 120, 15);
        jLayeredPane10.add(jLabel13, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel15.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel15.setText("Email Address :");
        jLabel15.setBounds(60, 110, 120, 15);
        jLayeredPane10.add(jLabel15, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel17.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel17.setText("Phone :");
        jLabel17.setBounds(60, 160, 120, 15);
        jLayeredPane10.add(jLabel17, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel19.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel19.setText("Gender :");
        jLabel19.setBounds(60, 210, 120, 15);
        jLayeredPane10.add(jLabel19, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel21.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel21.setText("Level :");
        jLabel21.setBounds(60, 260, 120, 15);
        jLayeredPane10.add(jLabel21, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel22.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel22.setText("Address :");
        jLabel22.setBounds(60, 300, 120, 15);
        jLayeredPane10.add(jLabel22, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel10.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel10.setBounds(260, 70, 170, 20);
        jLayeredPane10.add(jLabel10, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel12.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel12.setBounds(260, 110, 190, 20);
        jLayeredPane10.add(jLabel12, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel14.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel14.setBounds(260, 160, 180, 20);
        jLayeredPane10.add(jLabel14, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel16.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel16.setBounds(260, 200, 190, 20);
        jLayeredPane10.add(jLabel16, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel18.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel18.setBounds(260, 250, 170, 20);
        jLayeredPane10.add(jLabel18, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel20.setFont(new java.awt.Font("Trebuchet MS", 1, 12));
        jLabel20.setBounds(260, 290, 180, 20);
        jLayeredPane10.add(jLabel20, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/View/changePassword.png"))); // NOI18N
        jButton9.setText("Change Password");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
        jButton9.setBounds(570, 60, 160, 40);
        jLayeredPane10.add(jButton9, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jTabbedPane1.addTab("", new javax.swing.ImageIcon(getClass().getResource("/View/cooltext1524109851.png")), jLayeredPane10); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 800, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 413, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(18, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

private void jLabel2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel2MouseClicked


    jLayeredPane7.setVisible(true);
    jLayeredPane4.setVisible(false);
    jLayeredPane2.setVisible(false);
    jLayeredPane3.setVisible(false);
    jLayeredPane8.setVisible(false);
    jLayeredPane9.setVisible(false);



     list1 = new DefaultListModel();
     ArrayList <String> registedcourse = new ArrayList<String>();
     ArrayList<Course> allcourse = new ArrayList<Course>();
     ArrayList <String> coursecode = new ArrayList<String>();
      ArrayList <String> coursename = new ArrayList<String>();

     
    try {
        
        
       int count = data.getcountcourses(student.getId());
      // jLabel23.setText("You registed : "+" " +count+" " +"courses !!" );
       
       if (count >=6){
       
           jButton1.setEnabled(false);
           jButton2.setEnabled(false);
           jButton3.setEnabled(false);
           jLabel23.setText("You already registed 6 Courses!!");
       }
         allcourse = data.getCourse();
        registedcourse = data.check(student.getId());
       
        for (int l = 0 ; l<allcourse.size(); l++){
        
           String code = allcourse.get(l).getId();
           String name = allcourse.get(l).getName();
           coursecode.add(code);
           coursename.add(name);
        }
        
        if (registedcourse.size() !=0){
        
        for (int i = 0; i < registedcourse.size(); i++) {
           
            if (coursecode.contains(registedcourse.get(i))){
            
                
                String code = registedcourse.get(i).toString();
                
               String name = data.get(code);
               for (int k = 0 ; k < coursename.size() ; k++){
               
                   if (coursename.contains(name)){
                   
                       coursename.remove(name);
                   }
               }
                
            }
          
        }
        for (int j = 0 ; j<coursename.size() ; j++){
            list1.addElement(coursename.get(j).toString());
            }
        }
        else {
        
             for (int j = 0 ; j<coursename.size() ; j++){
            list1.addElement(coursename.get(j).toString());
        }
        }
        
//        ArrayList <String> course = new ArrayList<String>();
//        course = data.check(student.getId());
//       // Course [] co = data.getCourse(course);
//        
//        for(int i = 0 ; i<course.size(); i++){
//        
//            list1.addElement(course.get(i));
//        }
        
        jList3.setModel(list1);
    } catch (Exception e) {

        System.out.println(e);
          JOptionPane.showMessageDialog(null, e.getMessage());
    }




}//GEN-LAST:event_jLabel2MouseClicked

private void jLayeredPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLayeredPane1MouseClicked
// TODO add your handling code here:
}//GEN-LAST:event_jLayeredPane1MouseClicked

private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseClicked
    jLayeredPane7.setVisible(false);
    jLayeredPane4.setVisible(true);
    jLayeredPane2.setVisible(false);
    jLayeredPane3.setVisible(false);
    jLayeredPane8.setVisible(false);
    jLayeredPane9.setVisible(false);
}//GEN-LAST:event_jTabbedPane1MouseClicked

private void jLabel3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel3MouseClicked

    jLayeredPane8.setVisible(true);
    jLayeredPane7.setVisible(false);
    jLayeredPane4.setVisible(false);
    jLayeredPane2.setVisible(false);
    jLayeredPane3.setVisible(false);
    jLayeredPane9.setVisible(false);
    
    ArrayList<String> list = new ArrayList<String>();
    
    list1 = new DefaultListModel();
    try {
//        Course[] courses = data.getRegisteredCourse(student.getId());
//        for (int i = 0; i < courses.length; i++) {
//            list1.addElement(courses[i].getName());
//        }
        
        list = data.getregistedcourses(student.getId());
        
        for(int i =0 ; i<list.size() ; i++){
        
            list1.addElement(list.get(i).toString());
        }
        
        jList2.setModel(list1);
        
    } catch (Exception e) {

        System.out.println("Error 1 !!!!!!!");
    }

}//GEN-LAST:event_jLabel3MouseClicked

private void jLabel4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel4MouseClicked


    jLayeredPane9.setVisible(true);
    jLayeredPane8.setVisible(false);
    jLayeredPane7.setVisible(false);
    jLayeredPane4.setVisible(false);
    jLayeredPane2.setVisible(false);
    jLayeredPane3.setVisible(false);
    
    
    ArrayList<String> registedCourses = new ArrayList<String>();
    
      int count = data.getcountcourses(student.getId());
      jLabel26.setText("You registed : "+" " +count+" " +"courses !!" );
      int allowed = 6 - count ;
      jLabel24.setText("You can regist :" +" " + allowed  +" "+  "Courses"+"**");
      
     registedCourses = data.getregistedcourses(student.getId());
     list1 = new DefaultListModel();
     
     for(int i = 0; i<registedCourses.size(); i++){
     
         list1.addElement(registedCourses.get(i).toString());
     }
    
     jList5.setModel(list1);
      


}//GEN-LAST:event_jLabel4MouseClicked

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed

    ArrayList<String> list = new ArrayList<String>();
   // ListModel myData = jList2.getModel();
     Object [] value = jList2.getSelectedValues();
    
    for(Object o : value){
    
        list.add(o.toString());
    }
//    int length = myData.getSize();
//    String[] arrData = new String[length];
//    for(int i = 0; i < list.size() ; i++)
//    {
//        arrData[i] = myData.getElementAt(i).toString();
//    }
    
    if(list.isEmpty()){
    
        jLabel27.setText("Select Courses To delete *");
    }
    else{
         Object o = jList2.getSelectedValue();
        jLabel27.setText(o.toString() + " : is deleted");
        data.deleteCourses(list);
        list1.remove(jList2.getSelectedIndex());
      
        
    }
}//GEN-LAST:event_jButton5ActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButton4ActionPerformed

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed


            
              ArrayList<String> list = new ArrayList<String>();
              Object [] value = jList3.getSelectedValues();
              
              for (Object o : value){
              list.add(o.toString());
              
              }
             int size = list.size();
             if (size <=6){
              list2 = new DefaultListModel();
             ListModel lst2 = jList4.getModel();
             for (int i =0 ; i < lst2.getSize(); i++){
              list2.addElement(lst2.getElementAt(i));
             }
//             List<String> courcesNameList = new ArrayList<String>();
//             ListModel lst2 = jList4.getModel();
//             for (int i =0 ; i < lst2.getSize(); i++){
//              courcesNameList.add(lst2.getElementAt(i).toString());
//             }
              if (jList3.isSelectionEmpty() == false){
              
                 
                  for (int i =0 ; i < list.size(); i++){
                  
                     list1.remove(jList3.getSelectedIndex());
                     String course = list.get(i);
                     list2.addElement(course);
                      
                  }
                 //jList4.getModel().
                  jList4.setModel(list2);
              }
             
              }
               
              else{
             
                 
                  JOptionPane.showMessageDialog(null, "Select only 6 courses");
              }
     
   
   
   
    
  
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed

     ArrayList<String> list = new ArrayList<String>();
              Object [] value = jList4.getSelectedValues();
              
              for (Object o : value){
              list.add(o.toString());
              
              }
              
              list1 = new DefaultListModel();
             ListModel lst2 = jList3.getModel();
             for (int i =0 ; i < lst2.getSize(); i++){
              list1.addElement(lst2.getElementAt(i));
             }
//             List<String> courcesNameList = new ArrayList<String>();
//             ListModel lst2 = jList4.getModel();
//             for (int i =0 ; i < lst2.getSize(); i++){
//              courcesNameList.add(lst2.getElementAt(i).toString());
//             }
              if (jList4.isSelectionEmpty() == false){
              
                 
                  for (int i =0 ; i < list.size(); i++){
                  
                     list2.remove(jList4.getSelectedIndex());
                     String course = list.get(i);
                     list1.addElement(course);
                     count--;
                      
                  }
                 //jList4.getModel().
                  jList3.setModel(list1);
              }
              if(count<6){
              
                  jButton1.setEnabled(true);
              }
    
    
    
}//GEN-LAST:event_jButton2ActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    
    if(list2.isEmpty()){
    
         JOptionPane.showMessageDialog(null,"You don't select courses");
    }
    else{
    addCourse();
    if (count >=6){
    
        jButton1.setEnabled(false);
       
    }
    else{
    
        jButton1.setEnabled(true);
    }
    if (check ==true){
    
       int size = list2.size();
       jLabel23.setText("You Registed :" +" "+ size+" "+"Courses");
    }
    remove();
    }
    
}//GEN-LAST:event_jButton3ActionPerformed

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
    try {
            new changeMyPassword(this, true, this).setVisible(true);
        
        } catch (UnsupportedLookAndFeelException ex) {
           System.out.println("222222222");
        }
}//GEN-LAST:event_jButton9ActionPerformed

public void remove(){
    
    if(check ==true){

       list2.clear();
     
    }
}




    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Home().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel27;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JLayeredPane jLayeredPane10;
    private javax.swing.JLayeredPane jLayeredPane2;
    private javax.swing.JLayeredPane jLayeredPane3;
    private javax.swing.JLayeredPane jLayeredPane4;
    private javax.swing.JLayeredPane jLayeredPane5;
    private javax.swing.JLayeredPane jLayeredPane6;
    private javax.swing.JLayeredPane jLayeredPane7;
    private javax.swing.JLayeredPane jLayeredPane8;
    private javax.swing.JLayeredPane jLayeredPane9;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JList jList3;
    private javax.swing.JList jList4;
    private javax.swing.JList jList5;
    private javax.swing.JList jList6;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPane5;
    private javax.swing.JScrollPane jScrollPane6;
    private javax.swing.JScrollPane jScrollPane7;
    private javax.swing.JScrollPane jScrollPane8;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable jTable1;
    // End of variables declaration//GEN-END:variables
}
